package io.github.harmonly.mapper;

import io.github.harmonly.entity.Finance;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FinanceMapper {

    @Select("select * from finance")
    List<Finance> getFinances();

    @Select("select * from finance where aid = #{aid}")
    List<Finance> getFinancesByAid(int aid);

    @Select("select * from finance where fid = #{fid}")
    Finance getFinance(int fid);

    @Insert("insert into finance(aid, money, `usage`, time) VALUES (#{aid}, #{money}, #{usage}, #{time})")
    int addFinance(Finance finance);

    @Delete("delete finance from finance where fid = #{fid}")
    int deleteFinance(int fid);

    @Update("update finance set aid = #{aid}, money = #{money}, `usage` = #{usage}, time = #{time} where fid = #{fid}")
    int editFinance(Finance finance);
}
